//
//  MainWindowController.m
//  MapMarker
//
//  Created by 罗亮富 on 2018/12/17.
//  Copyright © 2018年 Roen. All rights reserved.
//

#import "MainWindowController.h"
#import "MainViewController.h"
#import <MapGisBusiness/LAMapSourceManager.h>

@interface MainWindowController ()

@property (weak) IBOutlet NSToolbar *tooBar;
@property (weak) IBOutlet NSSegmentedControl *mapSrcSwitchSegCtrl;

@end

@implementation MainWindowController

- (void)windowDidLoad {
    [super windowDidLoad];
    
    NSArray *srces = [LAMapSourceManager allMapSources];
    NSUInteger i = 0;
    for(LAMapSource *mpsrc in srces){
        [self.mapSrcSwitchSegCtrl setLabel:mpsrc.name forSegment:i];
        [self.mapSrcSwitchSegCtrl setWidth:80 forSegment:i];
        i++;
    }

}

#pragma mark- actions

- (IBAction)mapsourceswitch:(NSSegmentedControl *)segCtrl {
    
    NSArray *srces = [LAMapSourceManager allMapSources];
    if(srces.count > segCtrl.selectedSegment) {
        LAMapSource *s = [srces objectAtIndex:segCtrl.selectedSegment];
        MainViewController *vc = (MainViewController *)self.contentViewController;
        [vc changeMapSource:s];
    }
}

@end
